//
//  YCQRCodeView.m
//  YCSchool
//
//  Created by gmall on 16/5/23.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCQRCodeView.h"

@interface YCQRCodeView ()
@property (weak ,nonatomic) UILabel *tipLabel;
@end

@implementation YCQRCodeView
@synthesize headerImageView = _headerImageView;
@synthesize nameLabel = _nameLabel;
@synthesize codeImageView = _codeImageView;

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.layer.cornerRadius = 10;
        self.layer.masksToBounds = YES;
        
        UIImageView *headImageView  = [[UIImageView alloc] init];
        headImageView.backgroundColor = [UIColor clearColor];
        headImageView.layer.cornerRadius = 50 / 2;
        headImageView.layer.masksToBounds = YES;
        [self addSubview:headImageView];
        _headerImageView = headImageView;
        
        [headImageView yc_setAvatorWithURLString:@"" forSize:CGSizeMake(50, 50)];
        
        [headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            [YCAdapter performOtherBlock:^{
                make.top.equalTo(self).offset(20);
            } IPhone6Block:^{
                make.top.equalTo(self).offset(48.5);//97
            } IPhone6pBlock:^{
                make.top.equalTo(self).offset(60);
            }];
            make.centerX.equalTo(self);
            make.width.height.equalTo(@50);
        }];
        
        UILabel *nameLabel = [[UILabel alloc] init];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.font = [UIFont systemFontOfSize:13];
        nameLabel.textColor = [UIColor darkGrayColor];
        nameLabel.text = @"无名小子-张三丰";
        [self addSubview:nameLabel];
        _nameLabel = nameLabel;
        
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headImageView.mas_bottom).offset(9);
            make.centerX.equalTo(self);
        }];
        
        
        UIImageView *codeImageView = [[UIImageView alloc] init];
        [self addSubview:codeImageView];
        _codeImageView = codeImageView;
        
        [codeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            [YCAdapter performOtherBlock:^{
                make.top.equalTo(nameLabel.mas_bottom).offset(20);
                make.width.height.equalTo(@130);
            } IPhone6Block:^{
                make.top.equalTo(nameLabel.mas_bottom).offset(54);
                make.width.height.equalTo(@173);//345
            } IPhone6pBlock:^{
                make.top.equalTo(nameLabel.mas_bottom).offset(54);
                make.width.height.equalTo(@200);
            }];
        }];
        
        UILabel *tipLabel = [[UILabel alloc] init];
        tipLabel.textAlignment = NSTextAlignmentCenter;
        tipLabel.font = [UIFont systemFontOfSize:13];
        tipLabel.textColor = [UIColor lightGrayColor];
        tipLabel.text = @"扫描二维码,立即加我为好友";
        [self addSubview:tipLabel];
        _tipLabel = tipLabel;
        
        [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(codeImageView.mas_bottom).offset(27);
            make.centerX.equalTo(self);
        }];
        
        [self mas_makeConstraints:^(MASConstraintMaker *make) {
            [YCAdapter performOtherBlock:^{
                make.bottom.equalTo(tipLabel.mas_bottom).offset(20);
            } IPhone6Block:^{
                make.bottom.equalTo(tipLabel.mas_bottom).offset(48.5);//97
            } IPhone6pBlock:^{
                make.bottom.equalTo(tipLabel.mas_bottom).offset(60);
            }];
            
        }];
        
    }
    return self;
}



@end
